home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / DTP / DTP_TEX / H067.ZIP / FONTABLE.PAS < prev    next >
Pascal/Delphi Source File  |  1991-04-14  |  4KB  |  153 lines

  1. {$A-,B-,D-,E-,F-,I+,L-,N-,O-,R-,S-,V-}
  2. {Compile with Turbo-Pascal 5.0}
  3. Program Fontable(Input,Output);
  4. {
  5.   This program generates Japanese font tables
  6.  
  7.   Author: Francois Jalbert
  8.               '
  9.   Date: November 1990
  10.  
  11.   Version: 1.0
  12.  
  13.   Date: April 1991
  14.  
  15.   Version: 2.0
  16.  
  17.   Modifications: - Added four kanjis.
  18.                  - Run-time parameters now supplied.
  19.                  - Extension is .JEM now.
  20.                  - Page format changed slightly.
  21.                  - Symbols now centered within tables.
  22.                  - Switched to \clearpage since better for tables.
  23. }
  24. Const
  25.   {Highest Bitmap number in JIS24}
  26.   BitmapMax=7806;
  27.   {Highest font number}
  28.   FontMax=60;
  29.   {Number of symbols in a font}
  30.   SymbolMax=128;
  31.   SymbolMax1=127;
  32.  
  33. Type
  34.   Bitmap0Range=0..BitmapMax;
  35.   Font0Range=0..FontMax;
  36.   Symbol0Range=0..SymbolMax1;
  37.  
  38. Var OutFile:Text;
  39.  
  40. Procedure FontTable(Var OutFile:Text);
  41. Var 
  42.   Bitmap:Bitmap0Range;
  43.   Font:Font0Range;
  44.   Symbol:Symbol0Range;
  45.   EUC1,EUC2:Integer;
  46. Begin
  47. Writeln(OutFile,'%JEM2TEX /NoSpace /NoPercent /LaTeX /EUC /Extended /3.0');
  48. Writeln(OutFile,'%');
  49. Writeln(OutFile,'\documentstyle[12pt]{article}');
  50. Writeln(OutFile,'\pagestyle{plain}');
  51. Writeln(OutFile,'\setlength{\oddsidemargin}{-0.5in} %0.5in margin left-right');
  52. Writeln(OutFile,'\setlength{\textwidth}{7.5in} %8.5in-2*0.5in');
  53. Writeln(OutFile,'\setlength{\topmargin}{-0.25in} %0.75in margin top-bottom');
  54. Writeln(OutFile,'\setlength{\textheight}{9.4in} %11.0in-2*0.75in');
  55. Writeln(OutFile,'\setlength{\footskip}{0.1in}');
  56. Writeln(OutFile,'\setlength{\footheight}{0.1in}');
  57. Writeln(OutFile,'\setlength{\headheight}{0pt}');
  58. Writeln(OutFile,'\setlength{\headsep}{0pt}');
  59. Writeln(OutFile,'\setlength{\topskip}{0pt}');
  60. Writeln(OutFile,'\setlength{\parindent}{0pt}');
  61. Writeln(OutFile,'\setlength{\tabcolsep}{4pt}');
  62. Writeln(OutFile,'\renewcommand{\baselinestretch}{0.85}');
  63. Writeln(OutFile,'\begin{document}');
  64. Writeln(OutFile,'\begin{Large}');
  65. Writeln(OutFile);
  66. Writeln(OutFile,'\vspace*{\fill}');
  67. Writeln(OutFile);
  68. For Bitmap:=0 To BitmapMax Do
  69.   Begin
  70.   Symbol:=Bitmap Mod SymbolMax;
  71.   Font:=Bitmap Div SymbolMax;
  72.   EUC1:=Trunc( (Bitmap-1) Div 94 );
  73.   EUC2:=(Bitmap-1)-94*EUC1;
  74.   EUC1:=EUC1+161;
  75.   EUC2:=EUC2+161;
  76.   If Symbol=0 Then
  77.     Begin
  78.     Writeln(OutFile,'\begin{table}[h]');
  79.     Writeln(OutFile,' \centering');
  80.     Writeln(OutFile,' \begin{tabular}{r|cccccccccccccccc|l}');
  81.     Writeln(OutFile,'  Code & \multicolumn{16}{c|}{Characters} & EUC \\ \hline')
  82.     End;
  83.   If (Symbol Mod 16)=0 Then Write(OutFile,Symbol:6,' ')
  84.   Else
  85.     If (Symbol Mod 16) in [5,10,15] Then Write(OutFile,'       ');
  86.   If Bitmap=0 Then Write(OutFile,'&  ')
  87.   Else
  88.     Begin
  89.     Write(OutFile,'&'+Chr(EUC1)+Chr(EUC2));
  90.     If (Symbol Mod 16) in [4,9,14] Then Writeln(OutFile)
  91.     Else
  92.       If (Symbol Mod 16)=15 Then
  93.         Begin
  94.         Write(OutFile,'& ',EUC1,',',EUC2);
  95.         If (Symbol<>SymbolMax1) And (Bitmap<>BitmapMax) Then 
  96.           Write(OutFile,' \\');
  97.         Writeln(OutFile)
  98.         End
  99.       Else
  100.         If Bitmap=BitmapMax Then Writeln(OutFile)
  101.     End;
  102.   If (Symbol=SymbolMax1) Or (Bitmap=BitmapMax) Then
  103.     Begin
  104.     Writeln(OutFile,' \end{tabular}');
  105.     Writeln(OutFile,'\caption{Font {\tt kanji'+Chr(Ord('a')+(Font Div 8))+
  106.             Chr(Ord('a')+(Font Mod 8))+'} (',(Bitmap-Symbol),'--',Bitmap,').}');
  107.     Writeln(OutFile,'\end{table}');
  108.     Writeln(OutFile);
  109.     If Bitmap=BitmapMax Then
  110.       Begin
  111.       Writeln(OutFile,'\vspace*{\fill}');
  112.       Writeln(OutFile)
  113.       End
  114.     Else
  115.       If (Font Mod 3)=2 Then 
  116.         Begin 
  117.         Writeln(OutFile,'\vspace*{\fill}');
  118.         Writeln(OutFile);
  119.         Writeln(OutFile,'\clearpage');
  120.         Writeln(OutFile);
  121.         Writeln(OutFile,'\vspace*{\fill}');
  122.         Writeln(OutFile)
  123.         End
  124.     End
  125.   End;
  126. Writeln(OutFile,'\end{Large}');
  127. Writeln(OutFile,'\end{document}')
  128. End;
  129.  
  130. Begin
  131. Writeln;
  132. Writeln('Japanese Font Tables Generation Program.');   {To make Borland happy}
  133. Writeln('Version 2.0 Copyright F. Jalbert 1991.');
  134. Writeln;
  135.  
  136. Write('Creating Japanese file fontable.jem');
  137. Assign(OutFile,'fontable.jem');
  138. Rewrite(OutFile);
  139. Writeln('.');
  140.  
  141. Write('Generating font tables');
  142. FontTable(OutFile);
  143. Writeln('.');
  144.  
  145. Write('Closing Japanese file fontable.jem');
  146. Close(OutFile);
  147. Writeln('.');
  148. Writeln;
  149.  
  150. Writeln('Japanese font tables generation completed.');
  151. Writeln
  152. End.
  153.